package com.ifacebox.client.tools;

import java.awt.Frame;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JProgressBar;

/**
 * @author znn
 */
public class FaceImageImportProgressBar extends JDialog {
    private static final long serialVersionUID = 1L;
    private final FaceLuckDrawConfig faceLuckDrawConfig;
    private JProgressBar progressBar;

    public FaceImageImportProgressBar(Frame frame, FaceLuckDrawConfig faceLuckDrawConfig) {
        super(frame);
        this.faceLuckDrawConfig = faceLuckDrawConfig;
        super.setTitle(frame.getTitle());
        super.setIconImage(frame.getIconImage());
        super.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        this.initComponent();
        super.add(this.progressBar);
        super.pack();
        super.setResizable(false);
        super.setLocationRelativeTo(null);
    }

    public void initComponent() {
        progressBar = new JProgressBar();
        progressBar.setString("加载数据中，请稍后...");
        progressBar.setMinimum(0);
        progressBar.setMaximum(faceLuckDrawConfig.getFaceImageFile() == null ? 0 : faceLuckDrawConfig.getFaceImageFile().length);
        progressBar.setStringPainted(true);
    }

    public void setValue(int value) {
        progressBar.setValue(value);
    }
}
